export const campaignSchema = {
  type: 'object',
  properties: {
    campaign: {
      type: 'object',
      properties: {
        name: { type: 'string' },
        status: { type: 'string', enum: ['ACTIVE', 'PAUSED'] },
        objective: { type: 'string', enum: ['OUTCOME_SALES', 'OUTCOME_ENGAGEMENT'] },
        special_ad_categories: {
          type: 'array',
          items: { type: 'string', enum: ['NONE'] }
        },
        buying_type: { type: 'string', enum: ['AUCTION'] },
        smart_promotion_type: { type: 'string', enum: ['GUIDED_CREATION', 'AUTOMATED_SHOPPING_ADS'] },

        daily_budget: { type: 'string' },
        lifetime_budget: { type: 'string' }
      },
      required: ['smart_promotion_type', 'name', 'status', 'objective', 'buying_type', 'special_ad_categories'],
      if: {
        properties: { smart_promotion_type: { const: 'GUIDED_CREATION' } },
        required: ['smart_promotion_type']
      },
      then: {
        properties: {
          is_budget_schedule_enabled: { type: 'boolean' }
        },
        required: ['is_budget_schedule_enabled'],
        if: {
          properties: { is_budget_schedule_enabled: { const: true } },
          required: ['is_budget_schedule_enabled']
        },
        then: {
          properties: {
            bid_strategy: { type: 'string', enum: ['COST_CAP', 'LOWEST_COST_WITHOUT_CAP', 'LOWEST_COST_WITH_BID_CAP'] },
            budget_type: { type: 'string', enum: ['daily_budget', 'lifetime_budget'] }
          },
          required: ['bid_strategy', 'budget_type'],
          if: {
            properties: { budget_type: { const: 'daily_budget' } },
            required: ['budget_type']
          },
          then: {
            properties: { daily_budget: { type: 'string' } },
            required: ['daily_budget']
          },
          else: {
            if: {
              properties: { budget_type: { const: 'lifetime_budget' } },
              required: ['budget_type']
            },
            then: {
              properties: { lifetime_budget: { type: 'string' } },
              required: ['lifetime_budget']
            }
          }
        }
      }
    }
  }
}
